<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head lang="en" th:replace="include/common/common :: commonHeader">
    <footer th:include="include/common/common :: layUiResource"></footer>
    <footer th:include="include/common/common :: blueCSSResource"></footer>
    <footer th:include="include/common/common :: zTreeCSSSource"></footer>
    <footer th:include="include/common/common :: zTreeJSSource"></footer>

    <script>
        layui.config({
            base: '/staticResource/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index' , 'table' , 'laydate'] , function () {
            var table = layui.table
                ,admin = layui.admin
                ,element = layui.element;

            $(document).on('click','.zTreeBtn' , function () {
                $("#zTreeOption").val($(this).attr('data'));
                let elementId = $(this).attr('id') , data = JSON.parse($(this).attr('data')) , i = '/a/layTips/treeSelectForm?isUpdateTree=false' , t = data.title;
                $.fn.blueJs.tools.active['layerOpen'].call(this , i , t);
            });

            let entityName = 'skuStock'
                ,pageSize = [[${pageSize}]]
                ,tableId = entityName + "-table-operate"
                ,cols = [
                [
                    {field:'id', title: 'ID', sort: true, hide:true, fixed: 'left'}
                    ,{field:'warCode', sort:true , title: '仓库代码'}
                    ,{field:'wareName', sort:true , title: '仓库名称'}
                    ,{field:'code', sort:true , title: '商品代码'}
                    ,{field:'barcode', sort:true , title: '商品条码'}
                    ,{field:'name', sort:true , title: '商品名称'}
                    ,{field:'qty', sort:true , title: '数量'}
                    ,{field:'oprice', sort:true , title: '单价'}
                    ,{field:'total', sort:true , title: '金额'}
                ]
            ];

            $(document).on('click' , '#' + entityName + 'SearchBtn' , function () {
                $.fn.blueJs.tools.active['layTable'].call(this , table , this , pageSize , cols , tableId);
            });

            $(document).ready(function () {
                let searchBtn = '#' + entityName + 'SearchBtn';
                $.fn.blueJs.tools.active['layTable'].call(this , table , searchBtn , pageSize , cols , tableId);
            });

            //监听工具条

            var active = {
                export: function(){
                    let formData = $(entityName + "SearchForm").serialize();
                    console.log(formData);
                    window.location.href = "/a/skuStock/fileDownload" + "?" + formData;
/*                    layui.router();
                    let i = "/a/" + entityName + "/form?isNewRecord=true" , t = "录入采购入库单";
                    $.fn.blueJs.tools.active['layerOpen'].call(this , i , t , 100 , 100);*/
                }
            };

            $('.' + entityName + '-table-operate-btn .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</head>
<body>
<input type="hidden" id="zTreeOption" value=""/>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">系统参数</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space10 layui-form-item">
                        <!--                        todo:id = entity + search + form-->
                        <form class="layui-form" id="skuStockSearchForm" th:object="${skuStock}" method="post" action="/a/skuStock/findPage">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">商品代码：</label>
                                    <thl:tml type="treeSelect" isShowCode="1" title = "商品代码" submitAttributeName="code" classStyle="layui-input-inline"
                                             url = "/a/goods/treeData" name = "code" id = "goods" submitValue = "*{goods.code}" showValue = "*{goods.name}"
                                             canSelectRoot = "false" canSelectParent = "false"/>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">仓库：</label>
                                    <thl:tml type="treeSelect" isShowCode="1" title = "仓库" submitAttributeName="warCode" classStyle="layui-input-inline"
                                             url = "/a/wareHouse/treeData" name = "warCode" id = "war" submitValue = "*{wareHouse.code}" showValue = "*{wareHouse.name}"
                                             canSelectRoot = "false" canSelectParent = "false"/>
                                </div>
                            </div>


                            <div class="layui-form-item">
                                <!--                        todo:blue-form-id = entity + search + form-->
                                <button type="button" class="layui-btn" id="skuStockSearchBtn" onsubmit="return false" blue-form-id="skuStockSearchForm">搜索</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body" >
                    <div class="layui-btn-group skuStock-table-operate-btn" id="tableBtn" style="margin-bottom: 10px;">
                        <button class="layui-btn layui-btn-sm" data-type="export">导出</button>
                    </div>
                    <table class="layui-hide" id="skuStock-table-operate" lay-filter="skuStock-table-operate"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>